package com.foreknow.dao.impl;

import com.foreknow.dao.AdminDao;
import com.foreknow.mapping.EntityMapping;
import com.foreknow.mapping.MappingFactory;
import com.foreknow.model.Admin;

import java.sql.SQLException;
import java.util.List;

public class AdminDaoImpl extends BaseDAO implements AdminDao {
    @Override
    public Admin isCheckLogin(String username, String password) throws SQLException {
        String sql = "select * from admin where username=? and password = ?";
        EntityMapping mapping =this.mappingFactory.getMap(MappingFactory.ADMIN_MAPPING);
        List<Object> list =  this.jdbcTemplate.query(sql,mapping,username,password);
        if(list.size()>0){
            return (Admin) list.get(0);
        }else{
            return null;
        }

    }
}
